//进书记录显示
function  addBooksRecord() {
    $.ajax({
        type: "GET",
        headers : {authorization:header},
        dataType: "json",
        async: true,
        url: "http://120.79.183.142/api/manageBooks/increaseList",
        success: function (result) {
            if(result.code === 200)
            {
                var liuzhi_record_data = result["data"];
                var liuzhi_record_num = liuzhi_record_data.length;
                for(var liuzhi_i=0; liuzhi_i<liuzhi_record_num; liuzhi_i++)
                {
                    var liuzhi_irow = liuzhi_record_data[liuzhi_i];
                    var bid = liuzhi_irow["bid"];
                    var bname = liuzhi_irow["bname"];
                    var admin_id = liuzhi_irow["admin_uid"];
                    var username = liuzhi_irow["username"];
                    var number = liuzhi_irow["number"];
                    var created_at = liuzhi_irow["created_at"];
                    var updated_at = liuzhi_irow["updated_at"];

                    var str = '<tr>' + '<td>' + bid + '</td><td>' + bname + '</td>' + '<td>' + admin_id + '</td><td>' + username + '</td><td>' + number + '</td><td>' + created_at + '</td><td>'
                        + updated_at + '</td></tr>';
                    $("#add_record_ma tbody:last").append(str);
                }
            }
            else
            {
                alert(data.data);
                location.reload();
            }

            add_record_dt();
        },
        error: function (r) {
            alert(r);
            location.reload();
        }
    })
}
//DataTable参数
function add_record_dt() {
    $("#add_record_ma").DataTable({
        destroy:true,
        language: {
            "sProcessing": "处理中...",
            "sLengthMenu": "显示 _MENU_ 项结果",
            "sZeroRecords": "没有匹配结果",
            "sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
            "sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",
            "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
            "sInfoPostFix": "",
            "sSearch": "搜索:",
            "sUrl": "",
            "sEmptyTable": "表中数据为空",
            "sLoadingRecords": "载入中...",
            "sInfoThousands": ",",
            "oPaginate": {
                "sFirst": "首页",
                "sPrevious": "上页",
                "sNext": "下页",
                "sLast": "末页"
            },
            "oAria": {
                "sSortAscending": ": 以升序排列此列",
                "sSortDescending": ": 以降序排列此列"
            }
        },
        order : [5,'desc']


    });
}

//删除记录
function deleteBooksRecord() {
    $.ajax({
        type: "GET",
        headers : {authorization:header},
        dataType: "json",
        async: true,
        url: "http://120.79.183.142/api/manageBooks/deleteList",
        success: function (result) {
            if(result.code === 200)
            {
                var liuzhi_record_data = result["data"];
                var liuzhi_record_num = liuzhi_record_data.length;
                for(var liuzhi_i=0; liuzhi_i<liuzhi_record_num; liuzhi_i++)
                {
                    var liuzhi_irow = liuzhi_record_data[liuzhi_i];
                    var bid = liuzhi_irow["bid"];
                    var bname = liuzhi_irow["bname"];
                    var admin_id = liuzhi_irow["admin_uid"];
                    var username = liuzhi_irow["username"];
                    var number = liuzhi_irow["number"];
                    var created_at = liuzhi_irow["created_at"];
                    var updated_at = liuzhi_irow["updated_at"];

                    var str = '<tr>' + '<td>' + bid + '</td><td>' + bname + '</td>' + '<td>' + admin_id + '</td><td>' + username + '</td><td>' + number + '</td><td>' + created_at + '</td><td>'
                        + updated_at + '</td></tr>';
                    $("#delete_record_ma tbody:last").append(str);
                }
            }
            else
            {
                alert(data.data);
                location.reload();
            }

            delete_record_dt();
        },
        error: function (r) {
            alert(r);
            location.reload();
        }
    })
}

//dataTable参数
function delete_record_dt() {
    $("#delete_record_ma").DataTable({
        destroy:true,
        language: {
            "sProcessing": "处理中...",
            "sLengthMenu": "显示 _MENU_ 项结果",
            "sZeroRecords": "没有匹配结果",
            "sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
            "sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",
            "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
            "sInfoPostFix": "",
            "sSearch": "搜索:",
            "sUrl": "",
            "sEmptyTable": "表中数据为空",
            "sLoadingRecords": "载入中...",
            "sInfoThousands": ",",
            "oPaginate": {
                "sFirst": "首页",
                "sPrevious": "上页",
                "sNext": "下页",
                "sLast": "末页"
            },
            "oAria": {
                "sSortAscending": ": 以升序排列此列",
                "sSortDescending": ": 以降序排列此列"
            }
        },
        order : [5,'desc']
    });
}